{% extends 'layout/base.html' %}

{% block content %}
<div class="row mt-5">
    <div class="col-lg-3">
        {% set active_nav = 'profile' %}
        {% include 'config/includes/sidebar.html' %}
    </div>
    <div class="col-lg-6">
        <h4>{{ 'Your' if current_user.id == user.id else user.username }} Profile</h4>

        <form action="{{ url_for('config.profile_save') }}" method="post">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">

            <div class="form-group row">
                <div class="col">
                    <label>User ID</label>
                </div>
                <div class="col">
                    {{ user.id }}
                </div>
            </div>

            <div class="form-group row">
                <div class="col">
                    <label>Username</label>
                </div>
                <div class="col">
                    {{ user.username }}
                </div>
            </div>

            <div class="form-group row">
                <div class="col">
                    <label for="full_name">Full Name</label>
                </div>
                <div class="col">
                    {% if auth_type != 'local' %}
                        {{ user.full_name }}
                    {% else %}
                        <input type="text" class="form-control" name="full_name" id="full_name" value="{{ user.full_name }}" required>
                    {% endif %}
                </div>
            </div>

            <div class="form-group row">
                <div class="col">
                    <label for="email">E-mail</label>
                </div>
                <div class="col">
                    {% if (auth_type == 'ldap') and (has_email_mapping == True) %}
                        {{ user.email }}
                    {% else %}
                        <input type="email" class="form-control" name="email" id="email" value="{{ user.email }}" required>
                    {% endif %}
                </div>
            </div>

            {% if auth_type == 'local' or (auth_type == 'ldap' and ldap_pwdchange) %}
            <h5 class="pb-0 mb-0">Change Password</h5>

            {% if auth_type == 'local' %}
            <div class="form-group">
                <small class="font-italic">{{ password_complexity }}</small>
            </div>
            {% else %}
            <div class="form-group"></div>
            {% endif %}

            <div class="form-group row">
                <div class="col">
                    <label for="existing_password">Existing Password</label>
                </div>
                <div class="col">
                    <input type="password" value="" name="existing_password" id="existing_password" class="form-control">
                </div>
            </div>

            <div class="form-group row">
                <div class="col">
                    <label for="new_password">New Password</label>
                </div>
                <div class="col">
                    <input type="password" value="" name="new_password" id="new_password" class="form-control">
                </div>
            </div>

            <div class="form-group row">
                <div class="col">
                    <label for="confirm_password">Confirm Password</label>
                </div>
                <div class="col">
                    <input type="password" value="" name="confirm_password" id="confirm_password" class="form-control">
                </div>
            </div>
            {% endif %}

            <div class="form-group">
                <button type="submit" class="btn btn-block btn-primary">save</button>
            </div>
        </form>
    </div>
    <div class="col-lg"></div>
</div>
{% endblock %}